﻿@using Smarly.Bussines.Model

@model BookTree

@{
	List<long> currentIds = new List<long>();
	getCurrentIds(Model, currentIds);
}

@functions
{

	public void getCurrentIds(BookTree m, List<long> list)
	{
		list.Add(m.Id);
		if (m.Parent != null)
			getCurrentIds(m.Parent, list);
	}

}

<div class="bs-docs-sidenav block-white">
	@Html.ActionLink("К списку книг", "Index", "Home", new { }, new { @class = "nav-to-home" })

	<h5><a class="brown-color" href="@Model.Book.Root.Url">@Model.Book.Root.Text</a></h5>

	<div class="block-content main-navigation">
		<ul>
			@Html.Partial("_TextTocPartial", Model.Book.Root.Children.Where(x => x.IsHead).ToList(), new ViewDataDictionary
									                                                        {
										                                                        new KeyValuePair<string, object>("ModelId", Model.Id), 
										                                                        new KeyValuePair<string, object>("CurrentIds", currentIds),
										                                                        new KeyValuePair<string, object>("TextIdPrefix", ViewBag.TextIdPrefix),
									                                                        })
		</ul>

	</div>
</div>
